#ifndef GAME_H
#define GAME_H

#include <QObject>
#include <QList>

typedef unsigned char BYTE;
struct pk_GameInfo
{
    BYTE 	player_count;
    BYTE 	unk1[7];
    BYTE 	char_Type[6][8];
    BYTE	char_name[6][80];
    quint32 account_id[6];
    quint16 char_lvl[6];
    BYTE	account[6][140];
};

class Game : public QObject
{
    Q_OBJECT
public:
    Game(quint64 GameId,
         quint16 GameMode,
         quint8 MaxPlayers,
         quint8 MaxLvl,
         quint8 MinLvl,
         QString GameDes,
         QString GameName,
         quint32 GameOnwer,
         QObject *parent = 0);
    ~Game();

    void AddPlayer(quint32 p){ _Players.append(p); }
    void RmPlayer(quint32 p){ _Players.removeOne(p); }
    quint64 GameId(){ return _GameId;}
    quint16 getGameMode(){ return _GameMode; }
    quint8 getMaxPlayers(){ return _MaxPlayers; }
    quint8 getMaxLvl(){ return _MaxLvl; }
    quint8 getMinLvl(){ return _MinLvl; }
    QString getGameDes(){ return _GameDes; }
    QString getGameName(){ return _GameName; }
    quint32 getGameOnwer(){ return _GameOnwer; }
    quint16 getGamePort(){ return _GamePort; }
    bool canJoin(){ return (_canJoin && (_Players.count() < _MaxPlayers )); }
    void setcanJoin(bool bl){ _canJoin = bl; }
    void setGamePort(quint16 port){ _GamePort=port; }
    QList<quint32>* getPlist() { return &_Players; }
    pk_GameInfo* getGInfo(){ return _GInfo; }
    void setGInfo(pk_GameInfo* ginfo){ _GInfo = ginfo;}

private:
    quint16 _GameMode;
    quint8 _MaxPlayers;
    quint8 _MaxLvl;
    quint8 _MinLvl;
    QString _GameDes;
    quint64 _GameId;
    quint8 _unkByte;
    QString _GameName;
    quint32 _GameOnwer;
    quint16 _GamePort;
    QList<quint32> _Players;
    pk_GameInfo* _GInfo;
    bool _canJoin;
};
#endif // GAME_H
